import type { BasicColumn, FormSchema } from '@/components/Table';
import { render } from '/@/utils/common/renderUtils';

export const searchFormSchema: FormSchema[] = [];

export const columns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    align: 'center',
  },
  {
    title: '父分类',
    dataIndex: 'parentName',
    align: 'center',
  },
  {
    title: '排序号',
    dataIndex: 'sortNo',
    align: 'center',
  },
  {
    title: '图片',
    dataIndex: 'imgPaths',
    align: 'center',
    customRender: render.renderImg,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    align: 'center',
    customRender: render.renderDate,
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    align: 'center',
    customRender: render.renderDate,
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '名称',
    field: 'name',
    colProps: {
      span: 24,
    },
    component: 'Input',
  },
  {
    label: '父分类',
    field: 'parentId',
    colProps: {
      span: 24,
    },
    component: 'JTreeSelect',
    componentProps: {
      hasChildField: 'is_leaf',
      pidValue: '0',
      dict: 'product_backend_cate,name,id',
      pidField: 'parent_id',
      converIsLeafVal: 0,
    },
  },
  {
    label: '排序号',
    field: 'sortNo',
    colProps: {
      span: 24,
    },
    component: 'InputNumber',
  },
  {
    label: '图片',
    field: 'imgPaths',
    colProps: {
      span: 24,
    },
    component: 'JImageUpload',
    componentProps: {
      bizPath: 'goods/backendcate',
      fileType: 'image',
    },
  },
];
